home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 May / SGI IRIX 6.5 Applications 2004 May.iso / dist / java3d.idb / usr / demos / java / j3d / programs / examples / PickTest / OctahedronITFA.java.z / OctahedronITFA.java
Encoding:
Java Source  |  2003-08-08  |  3.4 KB  |  109 lines

  1. /*
  2.  *    @(#)OctahedronITFA.java 1.8 02/04/01 15:03:41
  3.  *
  4.  * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  *
  10.  * - Redistributions of source code must retain the above copyright
  11.  *   notice, this list of conditions and the following disclaimer.
  12.  *
  13.  * - Redistribution in binary form must reproduce the above copyright
  14.  *   notice, this list of conditions and the following disclaimer in
  15.  *   the documentation and/or other materials provided with the
  16.  *   distribution.
  17.  *
  18.  * Neither the name of Sun Microsystems, Inc. or the names of
  19.  * contributors may be used to endorse or promote products derived
  20.  * from this software without specific prior written permission.
  21.  *
  22.  * This software is provided "AS IS," without a warranty of any
  23.  * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
  24.  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
  25.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
  26.  * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
  27.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  28.  * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
  29.  * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
  30.  * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
  31.  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
  32.  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
  33.  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  34.  *
  35.  * You acknowledge that Software is not designed,licensed or intended
  36.  * for use in the design, construction, operation or maintenance of
  37.  * any nuclear facility.
  38.  */
  39.  
  40. import javax.media.j3d.*;
  41. import javax.vecmath.*;
  42.  
  43. class OctahedronITFA extends IndexedTriangleFanArray {
  44.   private static final int[] sVertCnt = {
  45.     6, 6
  46.   };
  47.   
  48.   OctahedronITFA() {
  49.     super(6, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 12, sVertCnt);  
  50.     
  51.     Point3f verts[] = new Point3f[6];
  52.     Color3f colors[] = new Color3f[6];
  53.     
  54.     verts[0] = new Point3f(0.0f,0.0f,-1.5f);
  55.     verts[1] = new Point3f(0.0f,0.0f,1.5f);
  56.     verts[2] = new Point3f(0.0f,-1.5f,0.0f);
  57.     verts[3] = new Point3f(0.0f,1.5f,0.0f);
  58.     verts[4] = new Point3f(1.5f,0.0f,0.0f);
  59.     verts[5] = new Point3f(-1.5f,0.0f,0.0f);
  60.  
  61.     colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
  62.     colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
  63.     colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
  64.     colors[3] = new Color3f(1.0f, 1.0f, 0.0f);
  65.     colors[4] = new Color3f(1.0f, 0.0f, 1.0f);
  66.     colors[5] = new Color3f(0.0f, 1.0f, 1.0f);
  67.  
  68.     int pntsIndex[] = new int[12];
  69.     int clrsIndex[] = new int[12];
  70.  
  71.     pntsIndex[0] = 4;
  72.     clrsIndex[0] = 4;
  73.     pntsIndex[1] = 2;
  74.     clrsIndex[1] = 2;
  75.     pntsIndex[2] = 0;
  76.     clrsIndex[2] = 0;
  77.     
  78.     pntsIndex[3] = 3;
  79.     clrsIndex[3] = 3;
  80.  
  81.     pntsIndex[4] = 1;
  82.     clrsIndex[4] = 1;    
  83.     
  84.     pntsIndex[5] = 2;
  85.     clrsIndex[5] = 2;
  86.  
  87.     pntsIndex[6] = 5;
  88.     clrsIndex[6] = 5;
  89.     pntsIndex[7] = 1;
  90.     clrsIndex[7] = 1;
  91.     pntsIndex[8] = 3;
  92.     clrsIndex[8] = 3;
  93.  
  94.     pntsIndex[9] = 0;
  95.     clrsIndex[9] = 0;
  96.  
  97.     pntsIndex[10] = 2;
  98.     clrsIndex[10] = 2;
  99.  
  100.     pntsIndex[11] = 1;
  101.     clrsIndex[11] = 1;
  102.  
  103.     setCoordinates(0, verts);
  104.     setCoordinateIndices(0, pntsIndex);
  105.     setColors(0, colors);
  106.     setColorIndices(0, clrsIndex);
  107.   }
  108. }
  109.